let url = process.argv.splice(2)[0];

let http = url.startsWith("https")?require("https"):require("http")
// 请求这个网址

http.get(url,(res)=>{
    let html = "";
    res.on("data",a=>html+=a)
    res.on("end",_=>{
        // 正则匹配
        html.match(/<img src=".*?"/g).forEach(e=>{dow(e)})
    })
})


let fs = require("fs")
function dow(url){
    let http = url.startsWith("https")?require("https"):require("http")
    http.get(url,(res)=>{
        res.pipe(fs.WriteStream("./"+url.match(/\/[^/]*$/)?.[0].substring(1)))
    })
}